﻿using BanHangWPF.Database;
using BanHangWPF.Model;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BanHangWPF.UserControls
{
    /// <summary>
    /// Interaction logic for NhapHangControl.xaml
    /// </summary>
    public partial class NhapHangControl : UserControl
    {
        public NhapHangControl()
        {
            InitializeComponent();
        }

        private void Save_Click(object sender, RoutedEventArgs e)
        {
            Hang hangmoi = new Hang(mahang.Text, tenhang.Text, donvihop.Text, donvivien.Text, int.Parse(soluongvien.Text), nhomhang.Text, motathem.Text);
            MySQLHelper mySQLHelper = new MySQLHelper();
            Debug.WriteLine("added "+ mySQLHelper.addHang(hangmoi));
        }

        private void Cancel_Click(object sender, RoutedEventArgs e)
        {

        }

        private void soluongvien_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            e.Handled = !Utility.CheckInput.AreAllValidNumericChars(e.Text);
            base.OnPreviewTextInput(e); 
        }

        
    }
}
